package com.mryan.metrics.utils;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @ClassName IdGenegor
 * @Description
 * @Author zhangdachen
 * @Date 2021-09-09 10:59
 * @Version V1.0
 **/
    public class IdGenerator {
        private AtomicLong id = new AtomicLong(0);
        private IdGenerator() {}

        private static class SingletonHolder{
            private static final IdGenerator instance = new IdGenerator();
        }

        public static IdGenerator getInstance() {
            return SingletonHolder.instance;
        }

        public long getId() {
            return id.incrementAndGet();
        }
    }




